<template>
  <div style="height: 100%; width: 100%; position: relative" ref="maindev">
    <div class="pagetop">
      <table style="width: 100%; font-size: 12px; white-space: nowrap" border="0">
        <col style="width: 5%" />
        <col style="width: 9%" />
        <col style="width: 1%" />
        <col style="width: 9%" />
        <col style="width: 4%" />
        <col style="width: 11%" />
        <col style="width: 4%" />
        <col style="width: 11%" />
        <col style="width: 5%" />
        <col style="width: 11%" />
        <col style="width: 5%" />
        <col style="width: 10%" />
        <col style="width: 4%" />
        <col style="width: 10%" />
        <tr>
          <td align="right">
            <el-dropdown @command="handleCommand" style="font-size: 12px">
              <u class="el-dropdown-link">
                {{ datename }}
              </u>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="标本日期">
                  <font font-size="12px">标本日期</font>
                </el-dropdown-item>
                <el-dropdown-item command="报告日期">
                  <font font-size="12px">报告日期</font>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </td>
          <td>
            <el-date-picker v-model="strdate" :clearable="false" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
              style="width: 100%"> </el-date-picker>
          </td>
          <td>至</td>
          <td>
            <el-date-picker v-model="enddate" type="date" :clearable="false" placeholder="选择日期" value-format="yyyy-MM-dd"
              style="width: 100%"> </el-date-picker>
          </td>
          <td align="right">科室</td>
          <td>
            <el-select v-model="reqdept" @dblclick.native="popMultipleChk(reqdept, 'reqdept', deptOption, '科室选择')"
              filterable clearable>
              <el-option v-for="(item, index) in deptOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
          </td>
          <td align="right">菌组</td>
          <td>
            <el-select width="100%" v-model="germcomb" filterable clearable>
              <el-option v-for="(item, index) in germcombOption" :value="item.data" :label="item.display"
                :key="index"></el-option>
            </el-select>
          </td>
          <td align="right">耐药机制</td>
          <td>
            <rm-ddl-common ref="ddlrescode" datatype="resdict" dataname="耐药机制" v-model="resistrule" width="100%"
              @change="resistruleChange" key="3"></rm-ddl-common>
          </td>
          <td align="right">标本类型</td>
          <td>
            <el-select v-model="sample" @dblclick.native="popMultipleChk(sample, 'sample', specimenOption, '请选择标本类型')"
              filterable clearable style="width: 100%">
              <el-option v-for="(item, index) in specimenOption" :key="index" :value="item.data"
                :label="item.display"></el-option>
            </el-select>
          </td>
          <td align="right">科室组</td>
          <td>
            <rm-ddl-common datatype="deptcomb" dataname="科室组" v-model="deptgroup" width="100%"
              @change="deptgroupChange"></rm-ddl-common>
          </td>
        </tr>
        <tr>
          <td align="right">报告单元</td>
          <td colspan="3">
            <rm-ddl-rptunit prgno="LIS922" v-model="rptunitid" clearable filterable @change="rptunitChange"
              :appendtobody="true" visible-change:true width="100%"></rm-ddl-rptunit>
          </td>
          <td align="right">病区</td>
          <td>
            <el-select v-model="reqward" @dblclick.native="popMultipleChk(reqward, 'reqward', wardOption, '病区选择')"
              filterable clearable>
              <el-option v-for="(item, index) in wardOption" :key="index" :value="item.data" :label="item.display">
              </el-option>
            </el-select>
          </td>
          <td align="right">性别</td>
          <td>
            <el-select v-model="patsex" placeholder="请选择性别" style="width: 100%">
              <el-option value="1" label="男">男</el-option>
              <el-option value="2" label="女">女</el-option>
              <el-option value="3" label="未知">未知</el-option>
            </el-select>
          </td>

          <td align="right">病人类型</td>
          <td>
            <rm-ddl-common datatype="seccode" kindno="PT" dataname="病人类型" v-model="pattype" @change="pattypeChange"
              width="100%"></rm-ddl-common>
          </td>
          <td align="right">送检医院</td>
          <td>
            <rm-ddl-common datatype="hospital" dataname="医院" v-model="hospcode" width="100%"
              @change="hospChange"></rm-ddl-common>
          </td>
          <td align="right">备注</td>
          <td>
            <el-select width="100%" v-model="reqcomm" filterable clearable>
              <el-option v-for="(item, index) in reportcommOption" :value="item.data" :label="item.display"
                :key="index"></el-option>
            </el-select>
          </td>
        </tr>
        <tr>
          <td align="right">统计方式</td>
          <td :colspan="4">
            <el-radio-group v-model="stattype" @change="stattypeChange">
              <el-radio :label="'1'" style="margin-right: 5px">科室</el-radio>
              <el-radio :label="'2'" style="margin-right: 5px">病区</el-radio>
              <el-radio :label="'3'" style="margin-right: 5px">标本类型</el-radio>
              <el-radio :label="'4'" style="margin-right: 5px">送检医院</el-radio>
            </el-radio-group>
          </td>

          <td :colspan="10" align="left">
            <el-checkbox true-label="1" false-label="0" v-model="bypat"><span
                style="font-size: 12px">按病人统计</span></el-checkbox>
          </td>
        </tr>

        <tr>
          <td colspan="14" align="right">
            <el-button @click.native="btnQuery" v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
            <el-button @click.native="BtnStatistics" icon="el-icon-edit-outline">统计</el-button>
            <el-button @click.native="btnClear" icon="el-icon-close">清除</el-button>
            <el-button @click.native="btnExport" icon="el-icon-download">导出</el-button>
            <el-button @click.native="BtnNextOne" icon="el-icon-thumb">下一个</el-button>
            <el-button @click.native="btndialogSaveAsgermGroup" icon="el-icon-document">存为菌组</el-button>
          </td>
        </tr>
      </table>
    </div>
    <div class="pagecenter">
      <rm-layout-left splitcolor="#FFFFFF" movingcolor="#CCFFFF" :splitwidth="5" :fixsize="350">
        <template v-slot:fix>
          <vxe-table :data.sync="leftTableData" :select-config="{ reserve: true }" :loading="leftloading"
            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="mytable-style"
            highlight-hover-column highlight-hover-row how-header-overflow ref="lXTable" resizable show-overflow
            size="mini" stripe show-header-overflow :optimization="{ animat: false }"
            :edit-config="{ trigger: 'dblclick', mode: 'cell' }" @cell-dblclick="DblEvent" header-align="center"
            show-footer>
            <vxe-table-column field="chkflag" title="选择" width="40" align="center">
              <template v-slot="{ row }">
                <el-checkbox true-label="1" false-label="0" v-model="row.chkflag"
                  @change="ChkflagChange(row)"></el-checkbox>
              </template>
            </vxe-table-column>
            <vxe-table-column field="rpt_itemname" sortable title="细菌名称" width="120" show-overflow></vxe-table-column>
            <vxe-table-column field="cp_germcnt" sortable title="检出数" align="center" width="60"
              show-overflow></vxe-table-column>
            <vxe-table-column field="cp_patcnt" sortable title="检出人次" align="center" width="70"
              show-overflow></vxe-table-column>
            <vxe-table-column field="chkcnt" sortable title="序号" align="center" width="50"
              show-overflow></vxe-table-column>
          </vxe-table>
        </template>
        <vxe-table :data.sync="rightTableData" :select-config="{ reserve: true }" :loading="rightloading"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="rTableStyle"
          highlight-hover-column highlight-hover-row how-header-overflow ref="rXTable" resizable show-overflow size="mini"
          stripe show-header-overflow :optimization="{ animat: false }" header-align="center" :key="xTablekey" show-footer
          :auto-resize="true" @cell-dblclick="DblClickEvent" :cell-class-name="cellClassName"
          :edit-config="{ trigger: 'dblclick', mode: 'cell' }">
          <vxe-table-column field="statname" sortable :title="statname" width="120" show-overflow></vxe-table-column>
          <vxe-table-column :field="items.field" :key="index" :title="items.title" :width="items.width" sortable
            v-for="(items, index) in tableColumn" align="center"></vxe-table-column>
        </vxe-table>
      </rm-layout-left>
    </div>

    <!--多选弹窗--->
    <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle"
      :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
      <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname"
        @change="closedialog"></rm-SqlMultiple>
    </el-dialog>
    <!--导出弹窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="导出"
      :visible.sync="dialogExport">
      <span>选择是则导出结果信息，选择否则导出结果明细信息，选择取消则取消本次导出！</span>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="exportfun(1)">是</el-button>
        <el-button type="primary" @click="exportfun(2)">否</el-button>
        <el-button @click="dialogExport = false">取 消</el-button>
      </span>
    </el-dialog>
    <!--存为细菌组弹窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="存为细菌组"
      :visible.sync="dialogSaveAsgermGroup" width="600px">
      <div style="height: 500px">
        <vxe-table :data.sync="popTableData" :select-config="{ reserve: true }" :loading="leftloading"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="mytable-style"
          highlight-hover-column highlight-hover-row how-header-overflow ref="lXTable" resizable show-overflow size="mini"
          stripe show-header-overflow :optimization="{ animat: false }" header-align="center" show-footer>
          <vxe-table-column field="chkflag" title="选择" width="50" align="center">
            <template v-slot="{ row }">
              <el-checkbox true-label="1" false-label="0" v-model="row.chkflag"
                @change="ChkflagChange(row)"></el-checkbox>
            </template>
          </vxe-table-column>
          <vxe-table-column field="rpt_itemname" sortable title="细菌名称" width="200" show-overflow></vxe-table-column>
          <vxe-table-column field="cp_germcnt" sortable title="检出数" align="center" width="80"
            show-overflow></vxe-table-column>
          <vxe-table-column field="cp_patcnt" sortable title="检出人次" align="center" width="80"
            show-overflow></vxe-table-column>
          <vxe-table-column field="chkcnt" sortable title="序号" align="center" width="60" show-overflow></vxe-table-column>
        </vxe-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-checkbox v-model="dialogSaveAsgermGroupChkAll" true-label="1" false-label="0"
          @change="chkAllChange">全选</el-checkbox>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <el-button type="primary" @click="SaveAsgermGroup">确 定</el-button>
        <el-button @click="dialogSaveAsgermGroup = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="poplefttitle"
      :visible.sync="dialogLpopdetail" width="1000px">
      <div style="height: 500px">
        <vxe-table :data.sync="popleftTableData" :select-config="{ reserve: true }" :loading="leftloading"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="mytable-style"
          highlight-hover-column highlight-hover-row how-header-overflow ref="poplXTable" resizable show-overflow
          size="mini" stripe show-header-overflow header-align="center" show-footer>
          <vxe-table-column field="reportid" sortable title="报告ID" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="rpt_itemcode" sortable title="报告项目代码" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="rpt_itemname" sortable title="报告项目名称" whdth="110" align="center"
            show-overflow></vxe-table-column>
          <vxe-table-column field="sampleno" sortable title="标本号" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="sampledate" sortable title="标本日期" width="70"
            :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
          <vxe-table-column field="specimen_name" sortable title="标本类型" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_name" sortable title="姓名" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_sexname" sortable title="性别" width="40" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_agestr" sortable title="年龄岁数" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="deptname" sortable title="科室" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="wardname" sortable title="病区" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_typecodename" sortable title="病人类别" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="emer_flag" title="加急 " width="40" header-align="center" align="center">
            <template v-slot="{ row }">
              <div style="color: red">{{ row.emer_flag == "1" ? "急" : "" }}</div>
            </template>
          </vxe-table-column>
        </vxe-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogLpopdetail = false">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="poprighttitle"
      :visible.sync="dialogRpopdetail" width="1000px">
      <div style="height: 500px">
        <vxe-table :data.sync="poprightTableData" :select-config="{ reserve: true }" :loading="leftloading"
          :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row class="mytable-style"
          highlight-hover-column highlight-hover-row how-header-overflow ref="poplXTable" resizable show-overflow
          size="mini" stripe show-header-overflow header-align="center" show-footer>
          <vxe-table-column field="statname" sortable :title="statname" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="sampleno" sortable title="标本号" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="sampledate" sortable title="标本日期" width="70"
            :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
          <vxe-table-column field="medcode" sortable title="药物代码" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="medname" sortable title="药物名称" width="110" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_name" sortable title="姓名" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_sexname" sortable title="性别" width="40" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_agestr" sortable title="年龄岁数" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="deptname" sortable title="科室" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="wardname" sortable title="病区" width="130" show-overflow></vxe-table-column>
          <vxe-table-column field="pat_typecodename" sortable title="病人类别" width="70" show-overflow></vxe-table-column>
          <vxe-table-column field="emer_flag" title="加急 " width="40" header-align="center" align="center">
            <template v-slot="{ row }">
              <div style="color: red">{{ row.emer_flag == "1" ? "急" : "" }}</div>
            </template>
          </vxe-table-column>
        </vxe-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogRpopdetail = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS922",
  data() {
    return {
      sexOption: [
        { label: "", value: "" },
        { label: "男", value: "1" },
        { label: "女", value: "2" },
      ],
      chargeflagOption: [
        { label: "未收费", value: "0" },
        { label: "已收费", value: "1" },
        { label: "等待退费", value: "8" },
        { label: "已退费", value: "9" },
        { label: "免费", value: "5" },
      ],
      is_showselother: false,
      dialogcountItem: false,
      dialogTableVisible1: false,
      dialogMultipleVisible: false,
      rightloading: false,
      leftloading: false,
      dialogExport: false,
      dialogSaveAsgermGroup: false,
      dialogSaveAsgermGroupChkAll: "0",
      option1: [],
      option2: [],
      fieldname: "",
      tableColumn: [
        { field: "germ1", title: "细菌1", width: "100" },
        { field: "germ2", title: "细菌2", width: "100" },
        { field: "germ3", title: "细菌3", width: "100" },
        { field: "germ4", title: "细菌4", width: "100" },
        { field: "germ5", title: "细菌5", width: "100" },
        { field: "germ6", title: "细菌6", width: "100" },
        { field: "germ7", title: "细菌7", width: "100" },
        { field: "germ8", title: "细菌8", width: "100" },
        { field: "germ9", title: "细菌9", width: "100" },
        { field: "germ10", title: "细菌10", width: "100" },
      ],
      leftTableData: [],
      rightTableData: [],
      popTableData: [],
      xTablekey: 0,
      datename: "标本日期",
      multichktitle: "",
      daytype: "1",
      pattypeOption: [],
      deptOption: [],
      wardOption: [],
      hospOption: [],
      doctorOption: [],
      rptunitOption: [],
      rptunitGroupOption: [],
      reportcommOption: [],
      germcombOption: [],
      specimenOption: [],
      //以下为查询条件
      strdate: this.$pub.InitDate(),
      enddate: this.$pub.InitDate(),
      reqdept: "",
      germcomb: "",
      resistrule: "",
      reqward: "",
      sample: "",
      rptunitid: "",
      deptgroup: "",
      patsex: "",
      pattype: "",
      hospcode: "",
      reqcomm: "",
      stattype: "1",
      bypat: "0",
      statname: "科室",
      popleftTableData: false,
      dialogLpopdetail: false,
      poprightTableData: false,
      dialogRpopdetail: false,
      poprighttitle: "细菌详细信息",
      poplefttitle: "详细信息",
      rpt_type: "1",
      rptunitname: "",
      pattypename: "",
      resistrulename: "",
      deptgroupname: "",
      hospname: "",
    };
  },
  created() {
    this.initOption();
    this.getOption();
  },
  mounted() { },
  updated() { },
  methods: {
    stattypeChange() {
      if (this.stattype == "1") {
        this.statname = "科室";
      } else if (this.stattype == "2") {
        this.statname = "病区";
      } else if (this.stattype == "3") {
        this.statname = "标本类型";
      } else {
        this.statname = "送检医院";
      }
    },
    popMultipleChk(e, fieldname, option, title) {
      let temp = XEUtils.clone(option, true);
      this.option1 = [];
      this.option2 = [];
      if (e != "") {
        let k = e.split(",");
        k.forEach((item) => {
          let ndata = temp.find((m) => m.data == item);
          if (ndata != undefined && ndata != null) {
            this.option2.push(ndata);
          }
        });
        temp.forEach((item) => {
          if (k.indexOf(item.data + "") < 0) {
            this.option1.push(item);
          }
        });
      } else {
        this.option1 = temp;
      }
      this.fieldname = fieldname;
      this.multichktitle = title;
      this.dialogMultipleVisible = true;
    },
    closedialog(value, name) {
      if (value != "close") {
        this[name] = value;
      }
      this.dialogMultipleVisible = false;
    },
    currentChangeEvent({ row, $rowIndex }) {
      this.currRowIndex = $rowIndex;
    },
    btnPrint(type) {
      if (rpt_amount > 0) {
        if (type == 3) {
          this.operate = "design";
        } else {
          this.operate = "";
        }
        var sql = "sp_print_PositiveList 'sqlwhere:" + this.sqlWhere + "','operate:'" + this.operate + "'";

        if (this.styleid) {
          this.$pub.printlistbill(this, sql, type, this.styleid, "总汇表", "");
        } else {
          this.$alert("未获取到打印样式id，请刷新页面后重试", "提示");
        }
      } else {
        this.$alert("未获取到数据！", "提示");
      }
    },
    handleCommand(name) {
      this.datename = name;
      if (name == "标本日期") {
        this.daytype = "1";
      } else {
        this.daytype = "2";
      }
    },
    getOption() {
      this.$tool
        .request({
          url: "LIS/LIS9/LIS922",
          method: "post",
          data: {
            action: "getOption",
            rptunitid: this.rptunitid,
          },
        })
        .then((res) => {
          this.reportcommOption = res.reportcommOption;
        })
        .catch((e) => {
          this.$alert(e, "出错");
        });
    },
    async initOption() {
      try {
        const res = await this.$tool.request({
          url: "LIS/LIS6/LIS610",
          method: "post",
          data: {
            action: "initOption",
          },
        });
        this.pattypeOption = res.pattypeOption;
        this.deptOption = res.deptOption;
        this.hospOption = res.hospOption;
        this.doctorOption = res.doctorOption;
        this.rptunitOption = res.rptunitOption;
        this.rptunitGroupOption = res.rptunitGroupOption;
        this.wardOption = res.wardOption;
        this.germcombOption = res.germcombOption;
        this.specimenOption = res.specimenOption;
        this.userOption = res.userOption;
      } catch (e) {
        this.$alert(e, "出错");
      }
    },
    btnQuery() {
      this.rightloading = true;
      this.leftloading = true;
      this.$tool
        .request({
          url: "LIS/LIS9/LIS922",
          method: "post",
          data: {
            action: "query",
            daytype: this.daytype,
            strdate: this.strdate,
            enddate: this.enddate,
            reqdept: this.reqdept,
            germcomb: this.germcomb,
            resistrule: this.resistrule,
            reqward: this.reqward,
            sample: this.sample,
            rptunitid: this.rptunitid,
            deptgroup: this.deptgroup,
            patsex: this.patsex,
            pattype: this.pattype,
            bypat: this.bypat,
            hospcode: this.hospcode,
            stattype: this.stattype,
            reqcomm: this.reqcomm,
          },
        })
        .then((response) => {
          if (response.errcode == "1") {
            response.Data.forEach((item, index) => {
              if (index < 10) {
                item.chkflag = "1";
                item.chkcnt = ++index;
              } else {
                item.chkflag = "0";
                item.chkcnt = 0;
              }
            });
            this.leftTableData = response.Data;
            this.tableColumn = response.MedData.cols;
            this.rightTableData = response.MedData.redt;
            ++this.xTablekey;
          } else {
            this.leftTableData = [];
            this.rightTableData = [];
            this.$alert("没有查询到符合条件的资料！", "信息", { confirmButtonText: "确定" });
          }
          this.rightloading = false;
          this.leftloading = false;
        })
        .catch((e) => {
          this.rightloading = false;
          this.leftloading = false;
          this.$alert(e, "出错");
        });
    },
    btnClear() {
      this.strdate = this.$pub.InitDate();
      this.enddate = this.$pub.InitDate();
      this.reqdept = "";
      this.germcomb = "";
      this.resistrule = "";
      this.reqward = "";
      this.sample = "";
      this.rptunitid = "";
      this.deptgroup = "";
      this.patsex = "";
      this.pattype = "";
      this.bypat = "0";
      this.hospcode = "";
      this.reqcomm = "";
      this.stattype = "1";
      this.statname = "科室";
      this.leftTableData = [];
      this.rightTableData = [];
    },
    btnExport() {
      this.dialogExport = true;
    },
    exportfun(index) {
      let extableColumn = [];
      if (index == "1") {
        let tableColumn = this.$refs.lXTable.getColumns();
        tableColumn.forEach((item) => {
          extableColumn.push({ title: item.title, field: item.property });
        });
        let filtertxt = this.getExportFilter();
        this.$pub.exportTableExcel(this.leftTableData, extableColumn, "LIS922 细菌分布-交叉10种菌result.xlsx", filtertxt, "统计条件：");
      } else {
        let tableColumn = this.$refs.rXTable.getColumns();
        tableColumn.forEach((item) => {
          extableColumn.push({ title: item.title, field: item.property });
        });
        let filtertxt = this.getExportFilter();
        this.$pub.exportTableExcel(this.rightTableData, extableColumn, "LIS922 细菌分布-交叉10种菌detail.xlsx", filtertxt, "统计条件：");
      }
      this.dialogExport = false;
    },
    // 获取当前导出文件的所有查询条件
    getExportFilter() {
      let filtertxt = this.datename + ":" + XEUtils.toDateString(this.strdate, "yyyy-MM-dd") + "至" + XEUtils.toDateString(this.enddate, "yyyy-MM-dd") + "; ";
      if (this.reqdept) filtertxt += "科室:" + this.getOptionName(this.deptOption.filter((item) => ("," + this.reqdept + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.germcomb) filtertxt += "菌组:" + this.getOptionName(this.germcombOption.filter((item) => this.germcomb == item.data)) + "; ";
      if (this.resistrule) filtertxt += "耐药机制:" + this.resistrulename + "; ";
      if (this.sample) filtertxt += "标本类型:" + this.getOptionName(this.specimenOption.filter((item) => ("," + this.sample + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.deptgroup) filtertxt += "科室组:" + this.deptgroupname + "; ";
      if (this.rptunitid) filtertxt += "报告单元:" + this.rptunitname + "; ";
      if (this.reqward) filtertxt += "病区:" + this.getOptionName(this.wardOption.filter((item) => ("," + this.reqward + ",").indexOf("," + item.data + ",") > -1)) + "; ";
      if (this.patsex) filtertxt += "性别:" + (this.patsex == "1" ? "男" : this.patsex == "2" ? "女" : "未知") + "; ";
      if (this.pattype) filtertxt += "病人类型:" + this.pattypename + "; ";
      if (this.hospcode) filtertxt += "送检医院:" + this.hospname + "; ";
      if (this.reqcomm) filtertxt += "备注:" + this.getOptionName(this.reportcommOption.filter((item) => this.reqcomm == item.data)) + "; ";
      if (this.stattype) filtertxt += "统计方式:" + this.statname + "; ";
      if (this.bypat == "1") filtertxt += "按病人统计; ";
      return filtertxt;
    },
    getOptionName(option) {
      if (option && option.length > 0) {
        let optionname = "";
        option.forEach((item) => {
          if (item.hasOwnProperty("display")) {
            optionname += item.display + ",";
          } else {
            optionname += item.label + ",";
          }
        });
        return optionname.substring(0, optionname.length - 1);
      } else {
        return "";
      }
    },
    deptchange() { },
    wardchange() { },
    specimenchange() { },
    rptunitChange(code, name) {
      this.rptunitid = code;
      this.rptunitname = name;
      this.getOption();
    },
    pattypeChange(code, name) {
      this.pattype = code;
      this.pattypename = name;
    },
    resistruleChange(code, name) {
      this.resistrule = code;
      this.resistrulename = name;
    },
    deptgroupChange(code, name) {
      this.deptgroup = code;
      this.deptgroupname = name;
    },
    hospChange(code, name) {
      this.hospcode = code;
      this.hospname = name;
    },
    BtnNextOne() {
      let data = this.$refs.lXTable.afterFullData;
      let fdata = data.filter((item) => item.chkflag == "1");
      let row = XEUtils.max(fdata, (item) => item.chkcnt);
      let rowindex = data.findIndex((m) => m.rpt_itemcode == row.rpt_itemcode);
      rowindex = rowindex + 1;
      let icnt = 0;
      for (let index = rowindex; index < rowindex + 10; index++) {
        data[index].chkflag = "1";
        data[index].chkcnt = ++icnt;
      }
      fdata.forEach((item) => {
        item.chkflag = "0";
        item.chkcnt = 0;
      });
      setTimeout(() => {
        this.$refs.lXTable.scrollToRow(row);
      }, 10);
      this.BtnStatistics();
    },
    //统计
    async BtnStatistics() {
      try {
        let data = this.$refs.lXTable.afterFullData;
        let fdata = data.filter((item) => item.chkflag == "1");
        if (fdata.length > 0) {
          this.rightloading = true;
          let rptitemnames = "";
          let rptitemcodes = "";
          fdata.forEach((item) => {
            rptitemnames += item.rpt_itemname + ",";
            rptitemcodes += item.rpt_itemcode + ",";
          });
          const response = await this.$tool.request({
            url: "LIS/LIS9/LIS922",
            method: "post",
            data: {
              action: "getDetail",
              rptitems: rptitemcodes,
              rptitemnames: rptitemnames,
              strdate: this.strdate,
              enddate: this.enddate,
              reqdept: this.reqdept,
              germcomb: this.germcomb,
              resistrule: this.resistrule,
              reqward: this.reqward,
              sample: this.sample,
              rptunitid: this.rptunitid,
              deptgroup: this.deptgroup,
              patsex: this.patsex,
              pattype: this.pattype,
              bypat: this.bypat,
              hospcode: this.hospcode,
              stattype: this.stattype,
              reqcomm: this.reqcomm,
            },
          });
          if (response.errcode == "1") {
            this.tableColumn = response.DetailData.cols;
            this.rightTableData = response.DetailData.redt;
            ++this.xTablekey;
          } else {
            this.$alert("查询出错", "提示");
            this.rightTableData = [];
          }
          this.rightloading = false;
        } else {
          this.$alert("请勾选统计项目", "提示");
        }
      } catch (e) {
        this.rightloading = false;
        this.$message.warning(e);
      }
    },
    //左边列表勾选
    ChkflagChange(row) {
      let data = this.$refs.lXTable.afterFullData;
      let fdata = {};
      if (row.chkflag == "1") {
        fdata = data.filter((item) => item.chkflag == "1");
        if (fdata.length <= 10) {
          fdata.forEach((item, index) => {
            item.chkcnt = ++index;
          });
        } else {
          this.$alert("一次最多可以选择10个细菌！", "提示");
          row.chkflag = "0";
        }
      } else {
        row.chkcnt = 0;
        fdata = data.filter((item) => item.chkcnt > 0);
        fdata.forEach((item, index) => {
          item.chkcnt = ++index;
        });
      }
    },
    btndialogSaveAsgermGroup() {
      this.popTableData = XEUtils.clone(this.leftTableData, true);
      this.dialogSaveAsgermGroup = true;
    },
    SaveAsgermGroup() {
      let data = this.popTableData.filter((item) => item.chkflag == "1");
      if (data.length > 0) {
        this.$prompt("请输入细菌组合名称", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          inputValue: data[data.length - 1].rpt_itemname,
          // inputPattern: /\s/,
          // inputErrorMessage: "请输入细菌组合名称",
        })
          .then(({ value }) => {
            this.$tool
              .request({
                url: "LIS/LIS9/LIS922",
                method: "post",
                data: {
                  action: "SaveAsgermGroup",
                  urec: data,
                  itemcombname: value,
                },
              })
              .then((response) => {
                if (response.errcode == "1") {
                  this.$pub.message(this, "保存成功!", "success");
                } else {
                  this.$alert(response.errmsg, "信息", { confirmButtonText: "确定" });
                }
              })
              .catch((e) => {
                this.$alert(e, "出错");
              });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "取消输入",
            });
          });
      }
    },
    chkAllChange() {
      if (this.dialogSaveAsgermGroupChkAll == "1") {
        this.popTableData.forEach((item) => {
          item.chkflag = "1";
        });
      } else {
        this.popTableData.forEach((item) => {
          item.chkflag = "0";
        });
      }
    },
    DblEvent({ row, rowIndex, $rowIndex, column }) {
      if (!row.rpt_itemcode) return;
      if (column.property == "cp_germcnt" || column.property == "cp_patcnt") {
        this.leftloading = true;
        if (column.property == "cp_germcnt") {
          this.poplefttitle = "检出数详细信息";
          this.rpt_type = "1";
        } else if (column.property == "cp_patcnt") {
          this.poplefttitle = "检出人次详细信息";
          this.rpt_type = "2";
        }
        this.$tool.request({
          url: "LIS/LIS9/LIS922",
          method: "post",
          data: {
            action: "queryDetail",
            rpt_type: this.rpt_type,
            rpt_itemcode: row.rpt_itemcode,
            daytype: this.daytype,
            strdate: this.strdate,
            enddate: this.enddate,
            reqdept: this.reqdept,
            germcomb: this.germcomb,
            resistrule: this.resistrule,
            reqward: this.reqward,
            sample: this.sample,
            rptunitid: this.rptunitid,
            deptgroup: this.deptgroup,
            patsex: this.patsex,
            pattype: this.pattype,
            bypat: this.bypat,
            hospcode: this.hospcode,
            stattype: this.stattype,
            reqcomm: this.reqcomm,
          },
        })
          .then((res) => {
            this.popleftTableData = XEUtils.clone(res.data, true);
            this.dialogLpopdetail = true;
            this.leftloading = false;
          })
          .catch((e) => {
            this.leftloading = false
          });
      }
    },
    DblClickEvent({ row, rowIndex, $rowIndex, column }) {
      this.poprighttitle = column.property + "详细信息";
      let data = this.$refs.lXTable.afterFullData;
      let fdata = data.filter((item) => item.chkflag == "1" && item.rpt_itemname == column.property);
      let rptitemcode = "";
      if (fdata.length > 0) {
        rptitemcode = fdata[0].rpt_itemcode;
      }

      this.$tool.request({
        url: "LIS/LIS9/LIS922",
        method: "post",
        data: {
          action: "getcntDetail",
          statname: row.statname,
          rpt_itemcode: rptitemcode,
          daytype: this.daytype,
          strdate: this.strdate,
          enddate: this.enddate,
          reqdept: this.reqdept,
          germcomb: this.germcomb,
          resistrule: this.resistrule,
          reqward: this.reqward,
          sample: this.sample,
          rptunitid: this.rptunitid,
          deptgroup: this.deptgroup,
          patsex: this.patsex,
          pattype: this.pattype,
          bypat: this.bypat,
          hospcode: this.hospcode,
          stattype: this.stattype,
          reqcomm: this.reqcomm,
        },
      })
        .then((res) => {
          this.poprightTableData = XEUtils.clone(res.DetailData, true);
          this.dialogRpopdetail = true;

        })
        .catch((e) => { });
    },
    cellClassName({ row, column }) {
      if (column.property != "statname") {
        if (!!row[column.property]) {
          return "sample-tips";
        }
      }
    },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 120px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 125px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-left {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}

.middle-right {
  position: absolute;
  height: 100%;
  left: 300px;
  right: 0px;
  overflow: auto;
}

.el-checkbox__label {
  padding: 0px;
}

.left_nav {
  width: 20%;
  height: 100%;
  border-right: 1px solid #ccc;
  padding: 0px 0px 0px 0px;
  float: left;
  display: inline;
}

.left_nav div {
  cursor: pointer;
  height: 40px;
  width: 100%;
  float: left;
  padding-left: 20px;
  line-height: 40px;
}

.left_nav .active {
  background-color: DeepSkyBlue;
}

.right_nav {
  width: 80%;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  float: left;
  display: inline;
}

table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}

.table1style tr td {
  padding: 0px 2px 0px 5px;
}

::v-deep  .sample-tips {
  color: blue;
  cursor: pointer;
  text-decoration: underline;
}

::v-deep .vxe-table .vxe-header--column.col--ellipsis:not(.col--actived) .vxe-cell {
  white-space: normal !important;
}

::v-deep  .mytable-style .vxe-footer--column.col-blue {
  color: blue !important;
  font-weight: bold;
}

::v-deep  .mytable-style .vxe-body--row.row-blue {
  color: blue !important;
  font-weight: bold;
}

::v-deep  .el-checkbox__label {
  padding-left: 0px;
}

::v-deep  .el-icon-time {
  line-height: 18px !important;
}

::v-deep  .el-range__close-icon {
  line-height: 18px !important;
}

::v-deep  .el-range-editor--small .el-range-separator {
  line-height: 17px !important;
}

::v-deep .el-input--suffix .el-input__inner {
  padding-right: 0px;
}

::-webkit-scrollbar {
  width: 0px;
  height: 5px;
  border: 4px solid white;
}

::-webkit-scrollbar-thumb {
  background-color: #c1c1c1;
}

::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

/* Buttons */
::-webkit-scrollbar-button:single-button {
  background-color: #bbbbbb;
  display: block;
  border-style: solid;
  height: 5px;
  width: 5px;
}

/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
  margin-right: 2px;
  border-width: 4px 4px 4px 0;
  border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
  background-color: #000000;
}

::-webkit-scrollbar-button:horizontal:decrement:hover {
  border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}

/* Right */
::-webkit-scrollbar-button:horizontal:increment {
  margin-left: 2px;
  border-width: 4px 0 4px 4px;
  border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
  background-color: #000000;
}

::-webkit-scrollbar-button:horizontal:increment:hover {
  border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}</style>
